//
//  HCUIDefines.h
//  HCToolBox
//
//  Created by Hotacool on 2019/3/20.
//

#ifndef HCUIDefines_h
#define HCUIDefines_h

#define hcScreenBoundsSize ([[UIScreen mainScreen] bounds].size)
#define hcScreenNativeBoundsSize ([[UIScreen mainScreen] nativeBounds].size)
#define hcScreenBoundsWidth ([[UIScreen mainScreen] bounds].size).width
#define hcScreenBoundsHeight ([[UIScreen mainScreen] bounds].size).height
#define hcScreenScale ([[UIScreen mainScreen] scale])
#define hcScreenNativeScale ([[UIScreen mainScreen] nativeScale])

#define  hcStatusBarAndNavigationBarHeight  (LL_iPhoneX ? 88.f : 64.f)

#define hcViewSafeAreInsets(view) ({UIEdgeInsets insets; if(@available(iOS 11.0, *)) {insets = view.safeAreaInsets;} else {insets = UIEdgeInsetsZero;} insets;})

CG_INLINE CGRect
hcSetRectX(CGRect rect, CGFloat x) {
    rect.origin.x = x;
    return rect;
}

CG_INLINE CGRect
hcSetRectY(CGRect rect, CGFloat y) {
    rect.origin.y = y;
    return rect;
}

CG_INLINE CGRect
hcSetRectXY(CGRect rect, CGFloat x, CGFloat y) {
    rect.origin.x = x;
    rect.origin.y = y;
    return rect;
}

CG_INLINE CGRect
hcSetRectWidth(CGRect rect, CGFloat width) {
    if (width < 0) {
        return rect;
    }
    rect.size.width = width;
    return rect;
}

CG_INLINE CGRect
hcSetRectHeight(CGRect rect, CGFloat height) {
    if (height < 0) {
        return rect;
    }
    rect.size.height = height;
    return rect;
}

/** 色值 RGB **/
#define hcRGB_A(r, g, b, a) [UIColor colorWithRed:(CGFloat)(r)/255.0f green:(CGFloat)(g)/255.0f blue:(CGFloat)(b)/255.0f alpha:(CGFloat)(a)]
#define hcRGB(r, g, b) hcRGB_A(r, g, b, 1)
#define hcRGB_HEX(__h__) hcRGB((__h__ >> 16) & 0xFF, (__h__ >> 8) & 0xFF, __h__ & 0xFF)
#define hcRGB_HEX_A(__h__, a) hcRGB_A((__h__ >> 16) & 0xFF, (__h__ >> 8) & 0xFF, __h__ & 0xFF, a)
#endif /* HCUIDefines_h */
